home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 November / CMCD1104.ISO / Software / Freeware / Grafica / galeroo / Setup Galleroo 3.4.exe / {app} / styles / Digum / gallery.xsl
Extensible Markup Language  |  2004-09-20  |  38KB  |  845 lines

  1. <?xml version='1.0'?>
  2. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
  3.                 xmlns:exsl="http://exslt.org/common" 
  4.                 xmlns:func="http://exslt.org/functions"
  5.                 xmlns:dyn="http://exslt.org/dynamic"
  6.                 xmlns:math="http://exslt.org/math"
  7.                 xmlns:str="http://exslt.org/strings"
  8.                 xmlns:g="."
  9.                 xmlns:galleroo="."
  10.                 extension-element-prefixes="dyn func exsl math str g galleroo" 
  11.                 version='1.1'>
  12. <xsl:include href="../Lib/galleroo.xsl" />
  13. <xsl:output method="html" /> 
  14.  
  15. <!-- doctype-public="-//W3C//DTD HTML 4.01 Transitional//EN" indent="yes" -->
  16.  
  17. <!-- Galleroo Digum XSL XML->HTML stylesheet 1.1
  18.      Copyright 2004, all rights reserved, xyster.net
  19.      written:     2/21/04
  20.      modified:  
  21.      author:     xyster
  22. -->
  23.  
  24. <xsl:param name="source-folder" />
  25. <xsl:param name="gallery-folder" />
  26. <xsl:param name="image-size">640</xsl:param>
  27. <xsl:param name="thumb-size">128</xsl:param>
  28. <xsl:param name="sort-by">date</xsl:param>
  29. <xsl:param name="title">Photo Gallery</xsl:param>
  30. <xsl:param name="sub-title" />
  31. <xsl:param name="html-file-prefix" />
  32. <xsl:param name="do-three-stage">no</xsl:param>
  33. <xsl:param name="do-auto-play-movies">no</xsl:param>
  34. <xsl:param name="template-folder" />
  35.  
  36. <xsl:param name="_preview">0</xsl:param>
  37.  
  38. <xsl:variable name="template-folder-uri" select="str:encode-uri($template-folder, 'UTF-8')" /> 
  39. <xsl:variable name="index-template" select="concat('/', $template-folder-uri, '/index.html')" />
  40. <xsl:variable name="slide-template" select="concat('/', $template-folder-uri, '/slide.html')" />
  41.  
  42. <xsl:variable name="params"> source-folder sort-by title sub-title thumb-size html-file-prefix do-auto-play-movies template-folder index-template slide-template do-three-stage </xsl:variable>
  43.  
  44.  
  45. <!-- functions -->
  46.  
  47. <!-- gets the number of thumbs declared in the index template -->
  48. <func:function name="g:thumbs-per-index">
  49.     <xsl:param name="doc" />
  50.     <xsl:choose> 
  51.         <xsl:when test="count($doc/html/gal-index/@io) != 0">
  52.             <func:result select="g:a(0, $doc/html/gal-index/@io)" />
  53.         </xsl:when>
  54.         <xsl:otherwise>
  55.             <func:result select="g:tmax($doc) - g:tmin($doc) + 1" />
  56.         </xsl:otherwise>
  57.     </xsl:choose>
  58. </func:function>
  59.  
  60. <!-- Calculates position based on i + offset -->
  61. <func:function name="g:a">
  62.     <xsl:param name="i" />
  63.     <xsl:param name="o" />                                  
  64.     <xsl:choose>
  65.         <xsl:when test="substring($o, 1, 1) = '+'">
  66.             <func:result select="$i + number(substring($o, 2, string-length($o) - 1))" />
  67.         </xsl:when>
  68.         <xsl:when test="string(number($o)) = 'NaN'">
  69.             <func:result select="$i" />
  70.         </xsl:when>
  71.         <xsl:otherwise>
  72.             <func:result select="$i + number($o)" />
  73.         </xsl:otherwise>
  74.     </xsl:choose>    
  75. </func:function>
  76.  
  77. <func:function name="g:valid-param">
  78.     <xsl:param name="p" />
  79.  
  80.     <func:result select="string-length(substring-after($params, $p)) != 0" />
  81. </func:function>    
  82.  
  83. <func:function name="g:tmax">
  84.     <xsl:param name="p" />
  85.     
  86.     <xsl:choose>
  87.     <xsl:when test="count($p/*) != 0">
  88.         <xsl:variable name="c">
  89.             <a>
  90.             <xsl:for-each select="$p/*">
  91.                 <o><xsl:value-of select="g:tmax(.)" /></o>
  92.             </xsl:for-each>
  93.             </a>
  94.         </xsl:variable>
  95.         <xsl:choose>
  96.             <xsl:when test="count(exsl:node-set($c)/a/o) != 0">
  97.                 <xsl:variable name="d" select="math:max(exsl:node-set($c)/a/o)" />
  98.                 <xsl:choose>
  99.                     <xsl:when test="$d < 0">
  100.                         <func:result select="g:a(0, $p/@io)" />
  101.                     </xsl:when>
  102.                     <xsl:otherwise>
  103.                         <func:result select="g:a($d, $p/@io)" />
  104.                     </xsl:otherwise>
  105.                 </xsl:choose>    
  106.             </xsl:when>
  107.             <xsl:otherwise>
  108.                 <func:result select="g:a(0, $p/@io)" />
  109.             </xsl:otherwise>
  110.         </xsl:choose>    
  111.     </xsl:when>
  112.     <xsl:otherwise>
  113.         <func:result select="g:a(0, $p/@io)" />
  114.     </xsl:otherwise>    
  115.     </xsl:choose>
  116. </func:function>
  117.  
  118. <func:function name="g:tmin">
  119.     <xsl:param name="p" />
  120.     
  121.     <xsl:choose>
  122.     <xsl:when test="count($p/*) != 0">
  123.         <xsl:variable name="c">
  124.             <a>
  125.             <xsl:for-each select="$p/*">
  126.                 <o><xsl:value-of select="g:tmin(.)" /></o>
  127.             </xsl:for-each>
  128.             </a>
  129.         </xsl:variable>
  130.         <xsl:choose>
  131.             <xsl:when test="count(exsl:node-set($c)/a/o) != 0">
  132.                 <xsl:variable name="d" select="math:min(exsl:node-set($c)/a/o)" />
  133.                 <xsl:choose>
  134.                     <xsl:when test="$d > 0">
  135.                         <func:result select="g:a(0, $p/@io)" />
  136.                     </xsl:when>
  137.                     <xsl:otherwise>
  138.                         <func:result select="g:a($d, $p/@io)" />
  139.                     </xsl:otherwise>
  140.                 </xsl:choose>    
  141.             </xsl:when>
  142.             <xsl:otherwise>
  143.                 <func:result select="g:a(0, $p/@io)" />
  144.             </xsl:otherwise>
  145.         </xsl:choose>    
  146.     </xsl:when>
  147.     <xsl:otherwise>
  148.         <func:result select="g:a(0, $p/@io)" />
  149.     </xsl:otherwise>    
  150.     </xsl:choose>
  151. </func:function>
  152.  
  153. <func:function name="g:ftl">
  154.     <xsl:param name="s" />
  155.     
  156.     <xsl:variable name="n1" select="string-length($s)" />
  157.     <xsl:variable name="n2" select="string-length(substring-before($s, ' '))" />
  158.     
  159.     <xsl:choose>
  160.         <xsl:when test="$n2 != 0">
  161.             <func:result select="$n2" />
  162.         </xsl:when>
  163.         <xsl:otherwise>
  164.             <func:result select="$n1" />
  165.         </xsl:otherwise>
  166.     </xsl:choose>        
  167. </func:function>
  168.  
  169. <xsl:template match="list">
  170.     
  171.     <!-- yummy! copy over the pix to a new *sorted* list
  172.     -->
  173.     <xsl:variable name="sorted-pix" select="exsl:node-set(galleroo:sort-pix(media/object/children/object/children/object, $sort-by))" />
  174.  
  175.     <xsl:variable name="maxi" select="count($sorted-pix/*)" />
  176.  
  177.     <xsl:variable name="iperj" select="g:thumbs-per-index(document($index-template))" />
  178.     
  179.     <xsl:variable name="maxj" select="floor(($maxi + ($iperj - 1)) div $iperj)" />
  180.     
  181.     <!-- index -->
  182.     <xsl:if test="count(document($index-template)/*) != 0">
  183.         <xsl:for-each select="$sorted-pix/*[position() mod $iperj = 1]">
  184.             <xsl:apply-templates select="document($index-template)" mode="gal">
  185.                 <xsl:with-param name="pix" select="$sorted-pix/*" />
  186.                 <xsl:with-param name="i" select="(position() - 1) * $iperj + 1" />
  187.                 <xsl:with-param name="maxi" select="$maxi" />
  188.                 <xsl:with-param name="j" select="position()" />
  189.                 <xsl:with-param name="maxj" select="$maxj" />
  190.                 <xsl:with-param name="iperj" select="$iperj" />
  191.             </xsl:apply-templates>
  192.  
  193.             <!-- cutter output -->
  194.             <xsl:call-template name="gal-emit-cutter-index">
  195.                 <xsl:with-param name="index" select="position()" />
  196.                 <xsl:with-param name="html-file-prefix" select="$html-file-prefix" />
  197.             </xsl:call-template>
  198.  
  199.         </xsl:for-each>
  200.     </xsl:if>    
  201.  
  202.     <!-- slide -->
  203.     <xsl:if test="count(document($slide-template)/*) != 0">
  204.         <xsl:for-each select="$sorted-pix/*">
  205.             <xsl:apply-templates select="document($slide-template)" mode="gal">
  206.                 <xsl:with-param name="pix" select="$sorted-pix/*" />
  207.                 <xsl:with-param name="i" select="position()" />
  208.                 <xsl:with-param name="maxi" select="$maxi" />
  209.                 <xsl:with-param name="j" select="floor((position() + ($iperj - 1)) div $iperj)" />
  210.                 <xsl:with-param name="maxj" select="$maxj" />
  211.                 <xsl:with-param name="iperj" select="$iperj" />
  212.             </xsl:apply-templates>
  213.  
  214.             <!-- cutter output -->
  215.             <xsl:text> </xsl:text>
  216.             <xsl:comment>CUTHERE: <xsl:value-of select="galleroo:rplstr(concat($html-file-prefix, attrib/name), '-', '\-')" />.html ?</xsl:comment>
  217.             <xsl:text> </xsl:text>
  218.           
  219.         </xsl:for-each>    
  220.     </xsl:if>
  221. </xsl:template>
  222.  
  223. <xsl:template match="*|node()" mode="gal">
  224.     <xsl:param name="pix" />
  225.     <xsl:param name="i" />
  226.     <xsl:param name="maxi" />
  227.     <xsl:param name="j" />
  228.     <xsl:param name="maxj" />
  229.     <xsl:param name="iperj" />
  230.     
  231.     <xsl:variable name="l" select="string-length(name())" />
  232.     <xsl:variable name="io" select="g:a($i, @io)" />
  233.     <xsl:variable name="jo" select="g:a($j, @jo)" />
  234.     
  235.     <xsl:choose>
  236.         
  237.         <!-- fancy directives -->
  238.  
  239.         <!-- super index generator -->
  240.         <xsl:when test="name() = 'gal-sindex'">
  241.             <!-- process everything inside -->
  242.         
  243.             <xsl:apply-templates mode="gal">
  244.                 <xsl:with-param name="pix" select="$pix" />
  245.                 <xsl:with-param name="i" select="$io" />
  246.                 <xsl:with-param name="maxi" select="$maxi" />
  247.                 <xsl:with-param name="j" select="$jo" />
  248.                 <xsl:with-param name="maxj" select="$maxj" />
  249.                 <xsl:with-param name="iperj" select="$iperj" />
  250.             </xsl:apply-templates>
  251.         
  252.             <!-- regenerate it again! -->
  253.            <xsl:copy-of select="." />        
  254.         </xsl:when>
  255.  
  256.         <!-- super hyper generic XPath conditional -->
  257.         <xsl:when test="name() = 'gal-if-xpath'">
  258.             <xsl:if test="dyn:evaluate(@test)">
  259.                 <xsl:apply-templates mode="gal">
  260.                     <xsl:with-param name="pix" select="$pix" />
  261.                     <xsl:with-param name="i" select="$io" />
  262.                     <xsl:with-param name="maxi" select="$maxi" />
  263.                     <xsl:with-param name="j" select="$jo" />
  264.                     <xsl:with-param name="maxj" select="$maxj" />
  265.                     <xsl:with-param name="iperj" select="$iperj" />
  266.                 </xsl:apply-templates>
  267.             </xsl:if>
  268.         </xsl:when>
  269.     
  270.         <!-- super hyper generic XPath expression evaluation -->
  271.         <xsl:when test="name() = 'gal-xpath'">
  272.             <xsl:value-of select="dyn:evaluate(@xpath)" />
  273.         </xsl:when>
  274.  
  275.         <!-- offsetter -->
  276.         <xsl:when test="name() = 'gal-offset'">
  277.             <xsl:choose>
  278.                 <xsl:when test="@absolute">
  279.                     <xsl:apply-templates mode="gal">
  280.                         <xsl:with-param name="pix" select="$pix" />
  281.                         <xsl:with-param name="i" select="g:a(0, @io)" />
  282.                         <xsl:with-param name="maxi" select="$maxi" />
  283.                         <xsl:with-param name="j" select="g:a(0, @jo)" />
  284.                         <xsl:with-param name="maxj" select="$maxj" />
  285.                         <xsl:with-param name="iperj" select="$iperj" />
  286.                     </xsl:apply-templates>
  287.                 </xsl:when>
  288.                 <xsl:otherwise>
  289.                     <xsl:apply-templates mode="gal">
  290.                         <xsl:with-param name="pix" select="$pix" />
  291.                         <xsl:with-param name="i" select="$io" />
  292.                         <xsl:with-param name="maxi" select="$maxi" />
  293.                         <xsl:with-param name="j" select="$jo" />
  294.                         <xsl:with-param name="maxj" select="$maxj" />
  295.                         <xsl:with-param name="iperj" select="$iperj" />
  296.                     </xsl:apply-templates>
  297.                 </xsl:otherwise>
  298.             </xsl:choose>        
  299.         </xsl:when>
  300.  
  301.         <!-- index cursor elements -->
  302.         
  303.         <xsl:when test="name() = 'gal-index'">
  304.             <!-- do nothing! -->
  305.         </xsl:when>
  306.         
  307.         <xsl:when test="name() = 'gal-if-index-valid'">
  308.             <xsl:if test="$jo > 0 and $jo <= $maxj">
  309.                 <xsl:apply-templates mode="gal">
  310.                     <xsl:with-param name="pix" select="$pix" />
  311.                     <xsl:with-param name="i" select="$io" />
  312.                     <xsl:with-param name="maxi" select="$maxi" />
  313.                     <xsl:with-param name="j" select="$jo" />
  314.                     <xsl:with-param name="maxj" select="$maxj" />
  315.                     <xsl:with-param name="iperj" select="$iperj" />            
  316.                 </xsl:apply-templates>
  317.             </xsl:if>
  318.         </xsl:when>
  319.     
  320.         <xsl:when test="name() = 'gal-if-index-not-valid'">
  321.             <xsl:if test="not ($jo > 0 and $jo <= $maxj)">
  322.                 <xsl:apply-templates mode="gal">
  323.                     <xsl:with-param name="pix" select="$pix" />
  324.                     <xsl:with-param name="i" select="$io" />
  325.                     <xsl:with-param name="maxi" select="$maxi" />
  326.                     <xsl:with-param name="j" select="$jo" />
  327.                     <xsl:with-param name="maxj" select="$maxj" />
  328.                     <xsl:with-param name="iperj" select="$iperj" />
  329.                 </xsl:apply-templates>
  330.             </xsl:if>
  331.         </xsl:when>
  332.         
  333.         <!-- gallery if/if-not directive -->
  334.         <xsl:when test="substring(name(), 1, 14) = 'gal-gallery-if'">
  335.             <xsl:variable name="p" select="substring(name(), 13, 6)" />
  336.             <xsl:variable name="a" select="substring(name(), 16, $l)" />
  337.             <xsl:variable name="an" select="substring(name(), 20, $l)" />
  338.             <xsl:choose>
  339.                 <xsl:when test="$p = 'if-not' and g:valid-param($an)">
  340.                     <xsl:if test="dyn:evaluate(concat('$', $an)) != @value" >
  341.                         <xsl:apply-templates mode="gal">
  342.                             <xsl:with-param name="pix" select="$pix" />
  343.                             <xsl:with-param name="i" select="$io" />
  344.                             <xsl:with-param name="maxi" select="$maxi" />
  345.                             <xsl:with-param name="j" select="$jo" />
  346.                             <xsl:with-param name="maxj" select="$maxj" />
  347.                             <xsl:with-param name="iperj" select="$iperj" />
  348.                         </xsl:apply-templates>
  349.                     </xsl:if>        
  350.                 </xsl:when>
  351.                 <xsl:when test="g:valid-param($a)">
  352.                     <xsl:if test="dyn:evaluate(concat('$', $a)) = @value" >
  353.                         <xsl:apply-templates mode="gal">
  354.                             <xsl:with-param name="pix" select="$pix" />
  355.                             <xsl:with-param name="i" select="$io" />
  356.                             <xsl:with-param name="maxi" select="$maxi" />
  357.                             <xsl:with-param name="j" select="$jo" />
  358.                             <xsl:with-param name="maxj" select="$maxj" />
  359.                             <xsl:with-param name="iperj" select="$iperj" />
  360.                         </xsl:apply-templates>
  361.                     </xsl:if>
  362.                 </xsl:when>
  363.             </xsl:choose>
  364.         </xsl:when>    
  365.  
  366.         <!-- image cursor elements -->
  367.     
  368.         <xsl:when test="name() = 'gal-if-image-valid'">
  369.             <xsl:if test="$io > 0 and $io <= $maxi">
  370.                 <xsl:apply-templates mode="gal">
  371.                     <xsl:with-param name="pix" select="$pix" />
  372.                     <xsl:with-param name="i" select="$io" />
  373.                     <xsl:with-param name="maxi" select="$maxi" />
  374.                     <xsl:with-param name="j" select="$jo" />
  375.                     <xsl:with-param name="maxj" select="$maxj" />
  376.                     <xsl:with-param name="iperj" select="$iperj" />
  377.                 </xsl:apply-templates>
  378.             </xsl:if>
  379.         </xsl:when>
  380.     
  381.         <xsl:when test="name() = 'gal-if-image-not-valid'">
  382.             <xsl:if test="not ($io > 0 and $io <= $maxi)">
  383.                 <xsl:apply-templates mode="gal">
  384.                     <xsl:with-param name="pix" select="$pix" />
  385.                     <xsl:with-param name="i" select="$io" />
  386.                     <xsl:with-param name="maxi" select="$maxi" />
  387.                     <xsl:with-param name="j" select="$jo" />
  388.                     <xsl:with-param name="maxj" select="$maxj" />
  389.                     <xsl:with-param name="iperj" select="$iperj" />
  390.                 </xsl:apply-templates>
  391.             </xsl:if>
  392.         </xsl:when>
  393.  
  394.         <!-- image conditional catch-all -->
  395.         <xsl:when test="substring(name(), 1, 12) = 'gal-image-if'">
  396.             <xsl:variable name="p" select="substring(name(), 11, 6)" />
  397.             <xsl:variable name="a" select="substring(name(), 14, $l)" />
  398.             <xsl:variable name="an" select="substring(name(), 18, $l)" />
  399.                 
  400.             <xsl:choose>
  401.                 <xsl:when test="$p = 'if-not'">
  402.                     <xsl:choose>
  403.                         <xsl:when test="substring($an, 1, 5) = 'iptc-'">
  404.                             <xsl:variable name="iname" select="galleroo:iptc-num($an)" />
  405.                             <xsl:variable name="cnt" select="count($pix[$io]/attrib/*[name() = $iname])" />
  406.                             <xsl:if test="($cnt != 0 and @value != $pix[$io]/attrib/*[name() = $iname]) or 
  407.                                           ($cnt  = 0 and @exists='1') or
  408.                                           ($cnt != 0 and @exists='0')">
  409.                                 <xsl:apply-templates mode="gal">
  410.                                     <xsl:with-param name="pix" select="$pix" />
  411.                                     <xsl:with-param name="i" select="$io" />
  412.                                     <xsl:with-param name="maxi" select="$maxi" />
  413.                                     <xsl:with-param name="j" select="$jo" />
  414.                                     <xsl:with-param name="maxj" select="$maxj" />
  415.                                     <xsl:with-param name="iperj" select="$iperj" />
  416.                                 </xsl:apply-templates>
  417.                             </xsl:if>
  418.                         </xsl:when>
  419.                         <xsl:otherwise>
  420.                             <xsl:variable name="cnt" select="count($pix[$io]/attrib/*[name() = $an])" />
  421.                             <xsl:if test="($cnt != 0 and @value != $pix[$io]/attrib/*[name() = $an]) or 
  422.                                           ($cnt  = 0 and @exists='1') or
  423.                                           ($cnt != 0 and @exists='0')">
  424.                                 <xsl:apply-templates mode="gal">
  425.                                     <xsl:with-param name="pix" select="$pix" />
  426.                                     <xsl:with-param name="i" select="$io" />
  427.                                     <xsl:with-param name="maxi" select="$maxi" />
  428.                                     <xsl:with-param name="j" select="$jo" />
  429.                                     <xsl:with-param name="maxj" select="$maxj" />
  430.                                     <xsl:with-param name="iperj" select="$iperj" />
  431.                                 </xsl:apply-templates>
  432.                             </xsl:if>
  433.                         </xsl:otherwise>
  434.                     </xsl:choose>
  435.                 </xsl:when>
  436.                 <xsl:otherwise>
  437.                     <xsl:choose>
  438.                         <xsl:when test="substring($a, 1, 5) = 'iptc-'">
  439.                             <xsl:variable name="iname" select="galleroo:iptc-num($a)" />
  440.                             <xsl:variable name="cnt" select="count($pix[$io]/attrib/*[name() = $iname])" />
  441.                             <xsl:if test="($cnt != 0 and @value = $pix[$io]/attrib/*[name() = $iname]) or 
  442.                                           ($cnt != 0 and @exists='1') or
  443.                                           ($cnt  = 0 and @exists='0')">
  444.                                 <xsl:apply-templates mode="gal">
  445.                                     <xsl:with-param name="pix" select="$pix" />
  446.                                     <xsl:with-param name="i" select="$io" />
  447.                                     <xsl:with-param name="maxi" select="$maxi" />
  448.                                     <xsl:with-param name="j" select="$jo" />
  449.                                     <xsl:with-param name="maxj" select="$maxj" />
  450.                                     <xsl:with-param name="iperj" select="$iperj" />
  451.                                 </xsl:apply-templates>
  452.                             </xsl:if>
  453.                         </xsl:when>
  454.                         <xsl:otherwise>
  455.                             <xsl:variable name="cnt" select="count($pix[$io]/attrib/*[name() = $a])" />
  456.                             <xsl:if test="($cnt != 0 and @value = $pix[$io]/attrib/*[name() = $a]) or 
  457.                                           ($cnt != 0 and @exists='1') or
  458.                                           ($cnt = 0 and @exists='0')">
  459.                                 <xsl:apply-templates mode="gal">
  460.                                     <xsl:with-param name="pix" select="$pix" />
  461.                                     <xsl:with-param name="i" select="$io" />
  462.                                     <xsl:with-param name="maxi" select="$maxi" />
  463.                                     <xsl:with-param name="j" select="$jo" />
  464.                                     <xsl:with-param name="maxj" select="$maxj" />
  465.                                     <xsl:with-param name="iperj" select="$iperj" />
  466.                                 </xsl:apply-templates>
  467.                             </xsl:if>
  468.                         </xsl:otherwise>
  469.                     </xsl:choose>
  470.                 </xsl:otherwise>
  471.             </xsl:choose>
  472.         </xsl:when>
  473.         
  474.         <!-- full image -->
  475.         <xsl:when test="name() = 'gal-image-full'">
  476.             <!-- the full size image/video -->
  477.             
  478.             <xsl:choose>
  479.             <!-- video -->
  480.             <xsl:when test="$pix[$io]/attrib/format = 'video'">
  481.             <div>
  482.                 <embed class="slide" src="{$pix[$io]/attrib/full-path}/{$pix[$io]/attrib/name}" mute="0" enablecontextmenu="1" showdisplay="0" autostart="{$do-auto-play-movies = 'yes'}" playcount="1" showcontrols="1" />
  483.             </div>
  484.             <div>
  485.                 <a href="{$pix[$io]/attrib/full-path}/{$pix[$io]/attrib/name}"><xsl:value-of select="galleroo:pretty-name($pix[$io]/attrib/name)" /> (<xsl:number value="$pix[$io]/attrib/file-size div 1024" grouping-separator="," grouping-size="3" />KB)</a>
  486.             </div> 
  487.             </xsl:when>
  488.             <!-- image -->
  489.             <xsl:otherwise>
  490.             <div>
  491.                 <img class="slide" src="{$pix[$io]/attrib/full-path}/{$pix[$io]/attrib/name}" border="0" />
  492.             </div>
  493.             </xsl:otherwise>
  494.             </xsl:choose>
  495.         </xsl:when>
  496.         
  497.         <!-- handle expression evaluation -->
  498.         <xsl:when test="name() = 'gal-eval'">
  499.             <xsl:call-template name="evaluator">
  500.                 <xsl:with-param name="s" select="@expr" />
  501.                 <xsl:with-param name="pix" select="$pix" />
  502.                 <xsl:with-param name="i" select="$io" />
  503.                 <xsl:with-param name="maxi" select="$maxi" />
  504.                 <xsl:with-param name="j" select="$jo" />
  505.                 <xsl:with-param name="maxj" select="$maxj" />
  506.             </xsl:call-template>
  507.         </xsl:when>
  508.         
  509.         <xsl:otherwise>
  510.             
  511.             <xsl:variable name="braced-name" select="concat('{', name(), '}')" />
  512.             
  513.             <!-- call our magic evaluator -->
  514.             <xsl:variable name="expanded">
  515.                 <xsl:call-template name="evaluator">
  516.                     <xsl:with-param name="s" select="$braced-name" />
  517.                     <xsl:with-param name="pix" select="$pix" />
  518.                     <xsl:with-param name="i" select="$io" />
  519.                     <xsl:with-param name="maxi" select="$maxi" />
  520.                     <xsl:with-param name="j" select="$jo" />
  521.                     <xsl:with-param name="maxj" select="$maxj" />
  522.                 </xsl:call-template>
  523.             </xsl:variable>
  524.             
  525.             <xsl:choose>
  526.             
  527.                 <!-- string expandable directives -->
  528.                 <xsl:when test="$expanded != name()">
  529.                     <xsl:value-of select="$expanded" />
  530.                 </xsl:when>
  531.                 
  532.                 <!-- recurse through -->
  533.                 <xsl:otherwise>
  534.                     <xsl:copy>
  535.                     <xsl:for-each select="@*[name() != 'io' and name() != 'jo']">
  536.                         <xsl:attribute name="{name()}">
  537.                             <xsl:call-template name="evaluator">
  538.                                 <xsl:with-param name="s" select="." />
  539.                                 <xsl:with-param name="pix" select="$pix" />
  540.                                 <xsl:with-param name="i" select="$io" />
  541.                                 <xsl:with-param name="maxi" select="$maxi" />
  542.                                 <xsl:with-param name="j" select="$jo" />
  543.                                 <xsl:with-param name="maxj" select="$maxj" />
  544.                             </xsl:call-template>
  545.                         </xsl:attribute>    
  546.                     </xsl:for-each>    
  547.                     <xsl:apply-templates mode="gal">
  548.                         <xsl:with-param name="pix" select="$pix" />
  549.                         <xsl:with-param name="i" select="$io" />
  550.                         <xsl:with-param name="maxi" select="$maxi" />
  551.                         <xsl:with-param name="j" select="$jo" />
  552.                         <xsl:with-param name="maxj" select="$maxj" />
  553.                         <xsl:with-param name="iperj" select="$iperj" />
  554.                     </xsl:apply-templates>
  555.                     </xsl:copy>
  556.                     </xsl:otherwise>
  557.             </xsl:choose>
  558.         </xsl:otherwise>
  559.     </xsl:choose>
  560.                             
  561. </xsl:template>
  562.  
  563. <xsl:template name="evaluator">
  564.     <xsl:param name="s" />
  565.     <xsl:param name="pix" />
  566.     <xsl:param name="i" />
  567.     <xsl:param name="maxi" />
  568.     <xsl:param name="j" />
  569.     <xsl:param name="maxj" />
  570.  
  571.     <xsl:choose>
  572.        <xsl:when test="contains($s, '{')">
  573.             <xsl:value-of select="substring-before($s, '{')" />
  574.             <xsl:variable name="expression" select="substring-before(substring-after($s, '{'), '}')" />
  575.             <xsl:variable name="expanded-expression">
  576.                 <xsl:call-template name="expander">
  577.                     <xsl:with-param name="s" select="$expression" />
  578.                     <xsl:with-param name="pix" select="$pix" />
  579.                     <xsl:with-param name="i" select="$i" />
  580.                     <xsl:with-param name="maxi" select="$maxi" />
  581.                     <xsl:with-param name="j" select="$j" />
  582.                     <xsl:with-param name="maxj" select="$maxj" />
  583.                 </xsl:call-template>
  584.             </xsl:variable>
  585.             
  586.             <xsl:value-of select="$expanded-expression" />
  587.             
  588.             <!-- evaluate the next expression down the line -->
  589.             <xsl:call-template name="evaluator">
  590.                 <xsl:with-param name="s" select="substring-after($s, '}')" />
  591.                 <xsl:with-param name="pix" select="$pix" />
  592.                 <xsl:with-param name="i" select="$i" />
  593.                 <xsl:with-param name="maxi" select="$maxi" />
  594.                 <xsl:with-param name="j" select="$j" />
  595.                 <xsl:with-param name="maxj" select="$maxj" />
  596.             </xsl:call-template>
  597.        </xsl:when>
  598.        <xsl:otherwise>
  599.             <xsl:value-of select="$s" />
  600.        </xsl:otherwise>
  601.     </xsl:choose>
  602. </xsl:template>
  603.  
  604. <xsl:template name="expander">
  605.     <xsl:param name="s" />
  606.     <xsl:param name="pix" />
  607.     <xsl:param name="i" />
  608.     <xsl:param name="maxi" />
  609.     <xsl:param name="j" />
  610.     <xsl:param name="maxj" />
  611.     
  612.     <!-- gal-gallery special cases -->
  613.     <xsl:variable name="n1">
  614.         <xsl:call-template name="rplstr">
  615.             <xsl:with-param name="value" select="$s"/>
  616.             <xsl:with-param name="from" select="'gal-gallery-generator'" />
  617.             <xsl:with-param name="to" select="$source-root/list/generator" />
  618.         </xsl:call-template>
  619.     </xsl:variable>
  620.     
  621.     <!-- gal-gallery catch all -->
  622.     <xsl:variable name="n2">
  623.         <xsl:call-template name="gal-gallery">
  624.             <xsl:with-param name="value" select="$n1" />
  625.         </xsl:call-template>
  626.     </xsl:variable>
  627.     
  628.     <!-- gal-image special cases -->
  629.     <xsl:variable name="n3">
  630.         <xsl:call-template name="rplstr">
  631.             <xsl:with-param name="value" select="$n2"/>
  632.             <xsl:with-param name="from" select="'gal-image-title'" />
  633.             <xsl:with-param name="to" select="galleroo:image-title($pix[$i]/attrib)" />
  634.         </xsl:call-template>
  635.     </xsl:variable> 
  636.     
  637.     <xsl:variable name="n4">
  638.         <xsl:call-template name="rplstr">
  639.             <xsl:with-param name="value" select="$n3"/>
  640.             <xsl:with-param name="from" select="'gal-image-comment'" />
  641.             <xsl:with-param name="to" select="galleroo:image-comment($pix[$i]/attrib)" />
  642.         </xsl:call-template>
  643.     </xsl:variable> 
  644.  
  645.     <xsl:variable name="n5">
  646.         <xsl:call-template name="rplstr">
  647.             <xsl:with-param name="value" select="$n4"/>
  648.             <xsl:with-param name="from" select="'gal-image-pretty-name'" />
  649.             <xsl:with-param name="to" select="galleroo:pretty-name($pix[$i]/attrib/name)" />
  650.         </xsl:call-template>
  651.     </xsl:variable> 
  652.  
  653.     <xsl:variable name="n6">
  654.         <xsl:call-template name="rplstr">
  655.             <xsl:with-param name="value" select="$n5" />
  656.             <xsl:with-param name="from" select="'gal-image-thumb-src'" />
  657.             <xsl:with-param name="to" select="concat($pix[$i]/attrib/thumb-path, '/', $pix[$i]/attrib/thumb-name)" />
  658.         </xsl:call-template>
  659.     </xsl:variable> 
  660.  
  661.     <xsl:variable name="n7">
  662.         <xsl:call-template name="rplstr">
  663.             <xsl:with-param name="value" select="$n6" />
  664.             <xsl:with-param name="from" select="'gal-image-full-src'" />
  665.             <xsl:with-param name="to" select="concat($pix[$i]/attrib/full-path, '/', $pix[$i]/attrib/name)" />
  666.         </xsl:call-template>
  667.     </xsl:variable> 
  668.  
  669.     <xsl:variable name="n8">
  670.         <xsl:call-template name="rplstr">
  671.             <xsl:with-param name="value" select="$n7" />
  672.             <xsl:with-param name="from" select="'gal-image-full-href'" />
  673.             <xsl:with-param name="to" select="concat($html-file-prefix, $pix[$i]/attrib/name, '.html')" />
  674.         </xsl:call-template>
  675.     </xsl:variable> 
  676.     
  677.     <xsl:variable name="n9"> 
  678.         <xsl:choose>
  679.             <xsl:when test="boolean($pix[$i]/attrib/original-path)">
  680.                 <xsl:call-template name="rplstr">
  681.                     <xsl:with-param name="value" select="$n8" />
  682.                     <xsl:with-param name="from" select="'gal-image-original-href'" />
  683.                     <xsl:with-param name="to" select="concat($pix[$i]/attrib/original-path, '/', $pix[$i]/attrib/name)" />
  684.                 </xsl:call-template>
  685.             </xsl:when>
  686.             <xsl:otherwise>
  687.                 <xsl:call-template name="rplstr">
  688.                     <xsl:with-param name="value" select="$n8" />
  689.                     <xsl:with-param name="from" select="'gal-image-original-href'" />
  690.                     <xsl:with-param name="to" select="''" />
  691.                 </xsl:call-template>
  692.             </xsl:otherwise>
  693.         </xsl:choose>    
  694.     </xsl:variable> 
  695.    
  696.     <xsl:variable name="n10">
  697.         <xsl:variable name="exposure" select="$pix[$i]/attrib/exposure-time" />
  698.         
  699.         <xsl:variable name="pretty-exposure">
  700.             <xsl:choose> 
  701.                 <xsl:when test="count($pix[$i]/attrib/exposure-time) = 0" />
  702.                 <xsl:when test="$exposure >= 1.0 or $exposure <= 0.0"><xsl:value-of select="$exposure" />"</xsl:when>
  703.                 <xsl:otherwise>1/<xsl:value-of select="round(1.0 div $exposure)" /></xsl:otherwise>
  704.             </xsl:choose>
  705.         </xsl:variable>
  706.         
  707.         <xsl:call-template name="rplstr">
  708.             <xsl:with-param name="value" select="$n9" />
  709.             <xsl:with-param name="from" select="'gal-image-exposure-time'" />
  710.             <xsl:with-param name="to" select="$pretty-exposure" />
  711.         </xsl:call-template>
  712.     </xsl:variable> 
  713.     
  714.     <xsl:variable name="n11">
  715.         <xsl:call-template name="rplstr">
  716.             <xsl:with-param name="value" select="$n10" />
  717.             <xsl:with-param name="from" select="'gal-image-num'" />
  718.             <xsl:with-param name="to" select="$i" />
  719.         </xsl:call-template>
  720.     </xsl:variable> 
  721.  
  722.     <xsl:variable name="n12">
  723.         <xsl:call-template name="rplstr">
  724.             <xsl:with-param name="value" select="$n11" />
  725.             <xsl:with-param name="from" select="'gal-image-max'" />
  726.             <xsl:with-param name="to" select="$maxi" />
  727.         </xsl:call-template>
  728.     </xsl:variable> 
  729.     
  730.     <!-- gal-image catch all -->
  731.     <xsl:variable name="n13">
  732.         <xsl:call-template name="gal-image">
  733.             <xsl:with-param name="value" select="$n12" />
  734.             <xsl:with-param name="pix" select="$pix" />
  735.             <xsl:with-param name="i" select="$i" />
  736.         </xsl:call-template>
  737.     </xsl:variable>
  738.     
  739.     <!-- index cases -->
  740.     <xsl:variable name="n14">
  741.         <xsl:call-template name="rplstr">
  742.             <xsl:with-param name="value" select="$n13" />
  743.             <xsl:with-param name="from" select="'gal-index-href'" />
  744.             <xsl:with-param name="to" select="concat($html-file-prefix, galleroo:index-html-name($j))" />
  745.         </xsl:call-template>
  746.     </xsl:variable>
  747.  
  748.     <xsl:variable name="n15">
  749.         <xsl:call-template name="rplstr">
  750.             <xsl:with-param name="value" select="$n14" />
  751.             <xsl:with-param name="from" select="'gal-index-max'" />
  752.             <xsl:with-param name="to" select="$maxj" />
  753.         </xsl:call-template>
  754.     </xsl:variable>
  755.  
  756.     <xsl:variable name="n16">
  757.         <xsl:call-template name="rplstr">
  758.             <xsl:with-param name="value" select="$n15" />
  759.             <xsl:with-param name="from" select="'gal-index-num'" />
  760.             <xsl:with-param name="to" select="$j" />
  761.         </xsl:call-template>
  762.     </xsl:variable>
  763.     
  764.     <xsl:value-of select="$n16" />
  765. </xsl:template>
  766.  
  767. <xsl:template name="gal-gallery">
  768.     <xsl:param name="value" />
  769.     
  770.     <xsl:variable name="base" select="'gal-gallery-'" />
  771.     
  772.     <xsl:choose>
  773.         <xsl:when test="contains($value, $base)">
  774.             <xsl:variable name="token-length" select="g:ftl(substring-after($value, $base))" />
  775.             <xsl:variable name="token-name" select="substring(substring-after($value, $base), 1, $token-length)" />
  776.             <xsl:value-of select="substring-before($value, $base)" />
  777.             <xsl:if test="g:valid-param($token-name)">
  778.                 <xsl:value-of select="dyn:evaluate(concat('$', $token-name))" />
  779.             </xsl:if>    
  780.             <xsl:call-template name="gal-gallery">
  781.                <xsl:with-param name="value" select="substring(substring-after($value, $base), $token-length + 1)" />
  782.             </xsl:call-template>
  783.         </xsl:when>
  784.         <xsl:otherwise>    
  785.             <xsl:value-of select="$value" />
  786.         </xsl:otherwise>
  787.     </xsl:choose>    
  788. </xsl:template>
  789.  
  790. <xsl:template name="gal-image">
  791.     <xsl:param name="value" />
  792.     <xsl:param name="pix" />
  793.     <xsl:param name="i" />
  794.     
  795.     <xsl:variable name="base" select="'gal-image-'" />
  796.     
  797.     <xsl:choose>
  798.         <xsl:when test="contains($value, $base)">
  799.             <xsl:variable name="token-length" select="g:ftl(substring-after($value, $base))" />
  800.             <xsl:variable name="token-name" select="substring(substring-after($value, $base), 1, $token-length)" />
  801.             
  802.             <xsl:value-of select="substring-before($value, $base)" />
  803.             <xsl:choose>
  804.                 <xsl:when test="substring($token-name, 1, 5) = 'iptc-'">
  805.                     <xsl:value-of select="galleroo:iptc($pix[$i]/attrib, $token-name)" />
  806.                 </xsl:when>
  807.                 <xsl:otherwise>
  808.                     <xsl:value-of select="$pix[$i]/attrib/*[name() = $token-name]" />
  809.                 </xsl:otherwise>    
  810.             </xsl:choose>
  811.             <xsl:call-template name="gal-image">
  812.                <xsl:with-param name="value" select="substring(substring-after($value, $base), $token-length + 1)" />
  813.                <xsl:with-param name="pix" select="$pix" />
  814.                <xsl:with-param name="i" select="$i" />                
  815.             </xsl:call-template>
  816.         </xsl:when>
  817.         <xsl:otherwise>    
  818.             <xsl:value-of select="$value" />
  819.         </xsl:otherwise>
  820.     </xsl:choose>    
  821. </xsl:template>
  822.  
  823. <xsl:template name="rplstr">
  824.     <xsl:param name="value" />
  825.     <xsl:param name="from" />
  826.     <xsl:param name="to" />
  827.  
  828.     <xsl:choose>
  829.         <xsl:when test="contains($value, $from)">
  830.             <xsl:value-of select="substring-before($value, $from)" />
  831.             <xsl:value-of select="$to" />
  832.             <xsl:call-template name="rplstr">
  833.                 <xsl:with-param name="value" select="substring-after($value, $from)" />
  834.                 <xsl:with-param name="from" select="$from" />
  835.                 <xsl:with-param name="to" select="$to" />
  836.             </xsl:call-template>
  837.        </xsl:when>
  838.        <xsl:otherwise>
  839.             <xsl:value-of select="$value" />
  840.        </xsl:otherwise>
  841.     </xsl:choose>
  842. </xsl:template>
  843.  
  844. </xsl:stylesheet>
  845.